<?php

require_once dirname(__FILE__).'/../lib/userGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/userGeneratorHelper.class.php';

/**
 * user actions.
 *
 * @package    cadsurvey
 * @subpackage user
 * @author     sharavdorj
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class userActions extends autoUserActions
{

  // LOGIN
  public function executeLogin(sfWebRequest $request)
  {
    $form = new LoginForm();

    if ($request->isMethod(sfRequest::POST))
    {
      $form->bind($request->getParameter($form->getName()));


      //checking user login action
      if ($form->isValid())
      {
        $admin = $form->getObject1();
        $this->getUser()->signIn($admin);
        $this->getUser()->setFlash('success', 'Амжилттай нэвтэрлээ.', true);
        $this->redirect("@homepage");
      }
    }

    $this->form = $form;
  }


  public function executeLogout(sfWebRequest $request)
  {
    $this->getUser()->signOut();
    $this->getUser()->setFlash('success', 'Холболт амжилттай тасарлаа.', true);
    $this->redirect('@login');
  }
}
